package com.dianxin.smartpark.manager.visitor.impl;

import com.chinatelecom.response.common.CommonResponseBody;
import com.chinatelecom.response.utils.BeanUtil;
import com.chinatelecom.response.utils.ResponseBodyWrapperUtil;
import com.dianxin.smartpark.dao.dataobject.visitor.SmartParkStrategyConfig;
import com.dianxin.smartpark.dao.dataobject.visitor.SmartParkStrategyConfigExample;
import com.dianxin.smartpark.dao.mapper.visitor.SmartParkStrategyConfigMapper;
import com.dianxin.smartpark.dao.qo.visitor.SmartParkStrategyConfigQO;
import com.dianxin.smartpark.manager.visitor.ISmartParkStrategyConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 访客策略配置Service业务层处理
 * 
 * @author chenjiasong
 * @date 2021-07-15
 */
@Service
public class ISmartParkStrategyConfigServiceImpl implements ISmartParkStrategyConfigService
{
    private final static Logger logger = LoggerFactory.getLogger(ISmartParkStrategyConfigServiceImpl.class);
    @Autowired
    private SmartParkStrategyConfigMapper smartParkStrategyConfigMapper;

    /**
     * 查询访客策略配置
     * 
     * @param id 访客策略配置ID
     * @return 访客策略配置
     */
    @Override
    public SmartParkStrategyConfig selectSmartParkStrategyConfigById(Long id)
    {
        return smartParkStrategyConfigMapper.selectByPrimaryKey(id);
    }

    /**
     * 查询访客策略配置列表
     * 
     * @param qo 访客策略配置
     * @return 访客策略配置
     */
    @Override
    public List<SmartParkStrategyConfig> selectSmartParkStrategyConfigList(SmartParkStrategyConfigQO qo)
    {
        SmartParkStrategyConfigExample smartParkStrategyConfigExample = new SmartParkStrategyConfigExample();
        SmartParkStrategyConfigExample.Criteria criteria = smartParkStrategyConfigExample.createCriteria();
        if (qo.getTenantId() != null) {
            criteria.andTenantIdEqualTo(qo.getTenantId());
        }
        criteria.andIsDeletedEqualTo(0);
        List<SmartParkStrategyConfig> passRecords = smartParkStrategyConfigMapper.selectByExample(smartParkStrategyConfigExample);
        return passRecords;
    }

    /**
     * 新增访客策略配置
     * 
     * @param smartParkStrategyConfig 访客策略配置
     * @return 结果
     */
    @Override
    public int insertSmartParkStrategyConfig(SmartParkStrategyConfig smartParkStrategyConfig)
    {
        // 验证 todo
        return smartParkStrategyConfigMapper.insert(smartParkStrategyConfig);
    }

    /**
     * 修改访客策略配置
     * 
     * @param smartParkStrategyConfig 访客策略配置
     * @return 结果
     */
    @Override
    public int updateSmartParkStrategyConfig(SmartParkStrategyConfig smartParkStrategyConfig)
    {
        // 验证 todo
        return smartParkStrategyConfigMapper.updateByPrimaryKeySelective(smartParkStrategyConfig);
    }

    /**
     * 删除访客策略配置信息
     * 
     * @param id 访客策略配置ID
     * @return 结果
     */
    @Override
    public int deleteSmartParkStrategyConfigById(Long id)
    {
        return smartParkStrategyConfigMapper.deleteByPrimaryKey(id);
    }
}
